import argparse

from app.jobs.pdfparser.internal.svc import svc
from app.jobs.pdfparser.internal.config import config
from app.jobs.pdfparser.internal.logic.consumer import PDFTaskConsumer
from app.jobs.pdfparser.internal.server.pdfparserserver import KafkaConsumerService
from common.utils import conf, logger


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--config", "-f", default="etc/pdfparser.yaml")
    args = parser.parse_args()

    c = conf.must_load_config(config.Config, args.config)
    logger.setup_logger(c.log.path)

    svcCtx = svc.ServiceContext(c)
    
    service = KafkaConsumerService(c.kafka_consumer_conf, PDFTaskConsumer(svcCtx))
    service.run_consumer()